---@diagnostic disable: lowercase-global, undefined-global
require "Multi-Widgets"
require "Single_Widgets"

mainWidgets_ContStyle = lvgl.style_t()
mainWidgets_ImgStyle = lvgl.style_t()

local function main_Widgets_Multi(b, e)
    if (e == lvgl.EVENT_CLICKED)then
        lvgl.obj_del(main_Widgets_Cont)
        Multi_WidgetsInit()
    end
end
local function main_Widgets_Single(b, e)
    if (e == lvgl.EVENT_CLICKED)then
        lvgl.obj_del(main_Widgets_Cont)
        Single_WidgetsInit()
    end
end

function main_WidgetsInit()

    lvgl.style_init(mainWidgets_ContStyle)
    lvgl.style_set_bg_color(mainWidgets_ContStyle, lvgl.STATE_DEFAULT, lvgl.color_hex(0x33CAFF))
    lvgl.style_set_radius(mainWidgets_ContStyle, lvgl.STATE_DEFAULT, lvgl.dpx(100))

    lvgl.style_init(mainWidgets_ImgStyle)
    lvgl.style_set_bg_opa(mainWidgets_ImgStyle, lvgl.STATE_DEFAULT, lvgl.OPA_0)
    lvgl.style_set_border_opa(mainWidgets_ImgStyle, lvgl.STATE_DEFAULT, lvgl.OPA_0)

    --总控件界面的基容器
    main_Widgets_Cont = lvgl.cont_create(lvgl.scr_act(), nil)
    lvgl.obj_set_size(main_Widgets_Cont, 480, 804)
	lvgl.obj_align(main_Widgets_Cont, nil, lvgl.ALIGN_IN_TOP_MID, 0, 50)
    lvgl.obj_add_style(main_Widgets_Cont, lvgl.CONT_PART_MAIN, mainPage_Style)

    --Widgets界面的多控件综合
    mainWidgest_MultiPage = lvgl.cont_create(main_Widgets_Cont, nil)
    lvgl.obj_set_size(mainWidgest_MultiPage, 400, 300)
	lvgl.obj_align(mainWidgest_MultiPage, main_Widgets_Cont, lvgl.ALIGN_IN_TOP_MID, 0, 50)
    lvgl.obj_add_style(mainWidgest_MultiPage, lvgl.CONT_PART_MAIN, mainWidgets_ContStyle)

    main_Widgets_btn1 = lvgl.btn_create(mainWidgest_MultiPage, nil)
    lvgl.obj_set_size(main_Widgets_btn1, 400, 300)
	lvgl.obj_align(main_Widgets_btn1, mainWidgest_MultiPage, lvgl.ALIGN_CENTER, 0, 0)
    lvgl.obj_add_style(main_Widgets_btn1, lvgl.BTN_PART_MAIN, mainWidgets_ImgStyle)
    lvgl.obj_set_event_cb(main_Widgets_btn1, main_Widgets_Multi)
    
    main_MultiWidgetsLabel = lvgl.label_create(main_Widgets_btn1, nil)
    lvgl.label_set_text(main_MultiWidgetsLabel, "多控件展示")
    lvgl.obj_align(main_MultiWidgetsLabel, main_Widgets_btn1, lvgl.ALIGN_CENTER, 0, 0)
    --lvgl.obj_add_style(main_MultiWidgetsLabel, lvgl.CONT_PART_MAIN, mainPage_FontStyle)
    
    --Widgets界面的单个控件
    mainWidgest_SinglePage = lvgl.cont_create(main_Widgets_Cont, nil)
    lvgl.obj_set_size(mainWidgest_SinglePage, 400, 300)
	lvgl.obj_align(mainWidgest_SinglePage, main_Widgets_Cont, lvgl.ALIGN_IN_TOP_MID, 0, 400)
    lvgl.obj_add_style(mainWidgest_SinglePage, lvgl.CONT_PART_MAIN, mainWidgets_ContStyle)
    
    main_Widgets_btn2 = lvgl.btn_create(mainWidgest_SinglePage, nil)
    lvgl.obj_set_size(main_Widgets_btn2, 400, 300)
	lvgl.obj_align(main_Widgets_btn2, mainWidgest_SinglePage, lvgl.ALIGN_CENTER, 0, 0)
    lvgl.obj_add_style(main_Widgets_btn2, lvgl.BTN_PART_MAIN, mainWidgets_ImgStyle)
    lvgl.obj_set_event_cb(main_Widgets_btn2, main_Widgets_Single)

    main_SingleWidgetsLabel = lvgl.label_create(main_Widgets_btn2, nil)
    lvgl.label_set_text(main_SingleWidgetsLabel, "单控件展示")
    lvgl.obj_align(main_SingleWidgetsLabel, main_Widgets_btn2, lvgl.ALIGN_CENTER, 0, 0)
    --lvgl.obj_add_style(main_SingleWidgetsLabel, lvgl.CONT_PART_MAIN, mainPage_FontStyle)

end